package com.gking.processHarvest.controller;

import com.gking.processHarvest.common.Res;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/permissions")
public class PermissionsController {


    @RequiresRoles("admin")
    @RequiresPermissions("user:delete")
    @PostMapping("/userDelete")
    public Res<String> userDelete() {
        return Res.success("需要 user:delete 权限， 并且是 admin 角色");
    }

    @RequiresPermissions("user:add")
    @PostMapping("/userAdd")
    public Res<String> userAdd() {
        return Res.success("需要 user:add 权限");
    }

    @RequiresPermissions("user:edit")
    @PostMapping("/userEdit")
    public Res<String> userEdit() {
        return Res.success("需要 user:edit 权限");
    }

    @RequiresPermissions("user:check")
    @PostMapping("/userCheck")
    public Res<String> userCheck() {
        return Res.success("需要 user:check 权限");
    }
}
